package org.social.controller;

import com.dal.gm_api.api.IServer;
import com.dal.gm_api.pojo.GMServerInfoDTO;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xiaoleilu.hutool.bean.BeanUtil;

import org.bean.GameServerInfo;
import org.social.manager.ServerStatusManager;
import org.utils.RemoteUtil;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * Created by fxf on 2018-1-9.
 */
public class GMServer implements IServer {


    @Override
    public List<String> getServerInfo(String serverId) {
        List<String> list = Lists.newArrayList();
        GameServerInfo info = RemoteUtil.loginSync().getServerInfo(serverId);
        if(info != null){
            list.add(info.toJsonString());
        }
        return list;
    }

    @Override
    public List<String> getServers() {
        List<GameServerInfo> gameServerInfoList = RemoteUtil.loginSync().getServers();
        List<String> list = Lists.newArrayList();
        gameServerInfoList.forEach(info -> list.add(info.toJsonString()));
        return list;
    }

    @Override
    public boolean operateServerStatus(int state) {
        RemoteUtil.gameTopic().operateServerState(state);
        ServerStatusManager.me().updateServerStatus(state);
        return true;
    }
}
